package cn.hp.service;

import cn.hp.dao.UserDao;
import cn.hp.util.PageBean;

import java.util.List;
import java.util.Map;

public class UserServiceImp implements UserService {
    UserDao dao = new UserDao();
    @Override
    public Map login(String name, String pwd) {
        List<Map> list = dao.select("select * from user where uusername=? and upassword=?", name, pwd);
        if(list!=null&&list.size()>0){
            return list.get(0);
        }else {
            return  null;
        }
    }

    @Override
    public List<Map> find(String sql,Object... obj) {
        return dao.select(sql,obj);
    }

    @Override
    public Map findById(String sql, int id) {
        return dao.findById(sql,id);
    }

    @Override
    public int del(String sql, int id) {
        return dao.update(sql, id);
    }

    @Override
    public int save(String sql, Object... obj) {
        return dao.update(sql, obj);
    }

    @Override
    public int upp(String sql, Object... obj) {
        return dao.update(sql, obj);
    }

    @Override
    public PageBean<Map> pageFind(int page, int limit, String sql, Object... obj) {
        return dao.pageList(page, limit, sql, obj);
    }
}
